

#define GPH2CON	(*(volatile unsigned long *)0xE0200C40)
#define GPH2DAT	(*(volatile unsigned long *)0xE0200C44)
#define GPH2PUD        (*(volatile unsigned long *)0xE0200C48)
#define GPD0CON  	(*(volatile unsigned long *)0xE02000A0)
#define GPD0DAT		(*(volatile unsigned long *)0xE02000A4)
#define GPH0CON  	(*(volatile unsigned long *)0xE0200C00)
#define GPH0DAT  	(*(volatile unsigned long *)0xE0200C04)
#define GPD0CON  	(*(volatile unsigned long *)0xE02000A0)
void init(void)
{

    GPD0CON&= ~(0xF << 0);
    GPH2CON = (GPH2CON & ~0x0000FFFF) | 0x00001111; 
    GPH2PUD=(0x55<<16)&GPH2PUD;
    GPH2DAT =0xf<<0;
    GPH0CON &=0x00000FFF;

}
void main(void)
{   
    init();
	while(1)//循环检测按键是否按下
	{

		if(GPH0DAT &(1<<0))//按键1未按下
		{
			GPH2DAT |=1<<0;//off
		}
		else//按键1按下
		{
			GPH2DAT &=~(1<<0);//on
		}
	       if(GPH0DAT &(1<<1))
		{
			GPH2DAT |=1<<1;//off
		}
		else
		{
			GPH2DAT &=~(1<<1);//on
		}
	        if(GPH0DAT &(1<<2))
		{
			GPH2DAT |=1<<2;//off
		}
		else
		{
			GPH2DAT &=~(1<<2);//on
		}
	        if(GPH0DAT &(1<<3))
		{
			GPH2DAT |=1<<3;//off
		}
		else
		{
			GPH2DAT &=~(1<<3);//on
		}
		
		if(GPH0DAT &(1<<4))//按键1未按下
		{
			GPH2DAT |=1<<0;//off
		}
		else//按键1按下
		{
			GPH2DAT &=~(1<<0);//on
		}
	       if(GPH0DAT &(1<<5))
		{
			GPH2DAT |=1<<1;//off
		}
		else
		{
			GPH2DAT &=~(1<<1);//on
		}
	        if(GPH0DAT &(1<<6))
		{
			GPH2DAT |=1<<2;//off
		}
		else
		{
			GPH2DAT &=~(1<<2);//on
		}
	        if(GPH0DAT &(1<<7))
		{
			GPH2DAT |=1<<3;//off
		}
		else
		{
			GPH2DAT &=~(1<<3);//on
		}
	}

}

